#include<iostream>
using namespace std;
const int N = 1e5 + 10;
int arr[N];
int mp[N * 2];
int n, b;	
int main()
{
	int idx = 0;
	cin >> n >> b;
	for (int i = 1; i <= n; i++) {
		cin >> arr[i];
		if (arr[i] == b) {
			idx = i;
		}
		else if (arr[i] > b) {
			arr[i] = 1;
		}
		else {
			arr[i] = -1;
		}
	}
	int ans = 1;
	int sum = 0;
	for (int i = idx + 1; i <= n; i++) {
		sum += arr[i];
		mp[n + sum]++;
		if (!sum) {
			ans++;
		}
	}
	sum = 0;
	for (int i = idx - 1; i >= 1; i--) {
		sum += arr[i];
		ans += mp[n - sum];
		if (!sum) {
			ans++;
		}
	}
	cout << ans << endl;
	return 0;
}